import { defineStore } from 'pinia'

export const configStore = defineStore('config', {
  state: () => ({
        config:{},
        currentBook:{}, //记录当前所选科目
        currentOpen:{} //记录当前阅读的章节
      }),
  actions: {
    setConfig(data) {
        this.config = data
      },
      getConfig(){
          return this.config
      },
      setBook(data){
          this.currentBook = data
      },
      getBook(){
          return this.currentBook
      },
      setCurrentOpen(data){
        this.currentOpen = data
      },
      getCurrentOpen(){
        return this.currentOpen
      }
  },
  persist: {
    enabled: true,
    strategies: [
      { storage: localStorage, paths: ['config'] }
    ]
  }
})